/***
 *
 * desc：api urls in app
 *
 */
import config from "./config.js";
import lang from "./i18/";
import {MD5} from "./";
const URL_ = {
    Get_LOGIN: '/login',
    Get_LOGOUT: '/logout',
    Get_USER: '/user-info/get',
    USER_UPDATE_PWD:'/user-info/modify-password',
    USER_UPDATE_PROFILE: '/teacher-info/updatePersonal',
    Get_USER_CLASS: '/class-info/find-associate-classes',
    Get_UPLOAD: '/upload-image',
    Get_UPLOAD_MULTIPLE: '/upload-image-multiple',

    //分类
    CATEGORY_ADD: '/classify-info/add', // add single news category
    CATEGORY_GET: '/classify-info/get', // get single news category
    CATEGORY_FIND: '/classify-info/find.json?type=1', //list news category
    CATEGORY_DELETE: '/classify-info/delete', //delete news category


    //新闻
    NEWS_GET: '/news-info/get', // get single news
    NEWS_FIND: '/news-info/find', // list news by pagination
    NEWS_DELETE: '/news-info/delete', // delete news
    NEWS_ADD: '/news-info/add', // add single news
    NEWS_UPDATE: '/news-info/edit', // add single news
    NEWS_PUSH_CLASS: '/news-info/pushed-class',// news push to classes
    NEWS_CATEGORY_FIND: '/classify-info/find.json?type=1',// activity category find

    //通知
    NOTICE_ADD: '/announce-info/add', // add single notice
    NOTICE_EDIT: '/announce-info/update', // add single notice
    NOTICE_GET: '/announce-info/get', // get single notice
    NOTICE_FIND: '/announce-info/find-own', // list notice by pagination
    NOTICE_DELETE: '/announce-info/delete', // delete notice
    NOTICE_UPDATE: '/announce-info/delete', // delete notice
    NOTICE_CATEGORY_FIND: '/classify-info/find.json?type=3', //1.新闻 2.活动 3.通知';

    //活动
    ACTIVITY_ADD: '/campaign-info/add', //delete activity
    ACTIVITY_MODIFY: '/campaign-info/edit', //modify activity
    ACTIVITY_GET: '/campaign-info/get', // get single activity
    ACTIVITY_FIND: '/campaign-info/find', // list activity by pagination
    ACTIVITY_FIND_PUSH_CLASS: '/campaign-info/pushed-class', // list activity by pagination
    ACTIVITY_DELETE: '/campaign-info/delete', //delete activity
    ACTIVITY_CATEGORY_FIND: '/classify-info/find.json?type=2',// activity category find


    CLASS_PROFILE_GET: '/class-info/get-current', // get class profile
    CLASS_PROFILE_SAVE: '/class-info/edit', // save class profile

    CLASS_HONOUR_CATEGORY_ADD: '',
    CLASS_HONOUR_CATEGORIES: '', //class honour list
    CLASS_HONOUR_FIND: '/honer-info/find', //class honour find
    CLASS_HONOUR_ADD: '/honer-info/add', //class honour add
    CLASS_HONOUR_TEACHER_STUDENT: '/teacher-student/find-all', //class honour add
    CLASS_HONOUR_DELETE: '/honer-info/delete', //class honour delete
    CLASS_HONOUR_MODIFY: '/honer-info/edit', //class honour modify
    CLASS_HONOUR_GET: '/honer-info/get', //class honour get

    CLASS_PHOTO_FIND: '/teacher-info/find-by-class',//list class photo
    CLASS_PHOTO_ADD: '',//add class photo
    CLASS_PHOTO_ADD_FOLDER: '',//add class photo folder
    CLASS_PHOTO_DELETE: '',//delete class photo
    CLASS_PHOTO_GET: '',//get class photo

    // CLASS_TEACHER_FIND: '/teacher-info/find-by-class',//list class teacher
    CLASS_TEACHER_FIND: '/teacher-info/findSameClassUserTeacherManager',//list class teacher
    CLASS_TEACHER_DETAIL: '/teacher-info/get',// teacherid:


    CLASS_STUDENT_FIND: '/student-info/findHeadteacherStudent',//list class student
    // CLASS_STUDENT_FIND: '/student-info/find',//list class student
    CLASS_STUDENT_ADD: '/student-info/add',//add class student
    CLASS_STUDENT_GET: '/student-info/get',//get class student
    CLASS_STUDENT_DELETE: '/student-info/delete',//list class student
    CLASS_STUDENT_MODIFY: '/student-info/edit',//list class student

    HOMEWORK_FIND: '/homework-info/find',
    HOMEWORK_ADD: '/homework-info/add',
    HOMEWORK_DELETE: '/homework-info/delete',
    HOMEWORK_GET: '/homework-info/get',
    HOMEWORK_MODIFY: '/homework-info/edit',


    SCHEDULE_FIND: '/subject-info/find',
    SCHEDULE_GET: '/time-table/get',
    SCHEDULE_CLASS_TIME_FIND: '/classtime-info/find-all',
    SCHEDULE_ADD: '/time-table/add',

    TEACH_SCHEDULE_FIND: '/teaching-info/find',
    TEACH_SCHEDULE_ADD_SUMMARY: '/teaching-info/add',
    // TEACH_SCHEDULE_ADD_SUMMARY: '/teaching-info/add',
    TEACH_SCHEDULE_ADD_ITEM: '/course-info/add',
    TEACH_SCHEDULE_FIND_ITEM: '/course-info/find',
    TEACH_SCHEDULE_UPDATE_ITEM: '/course-info/edit',//courseid：‘’
    TEACH_SCHEDULE_DELETE_ITEM: '/course-info/delete', //courseid:
    TEACH_SCHEDULE_DELETE: '/teaching-info/delete',
    TEACH_SCHEDULE_GET: '/teaching-plan/get',
    TEACH_SCHEDULE_MODIFY: '/teaching-info/edit',

    //每日一新
    DAY_NEWS_FIND: '/daytopic-info/find',
    DAY_NEWS_ADD: '/daytopic-info/add',
    DAY_NEWS_DELETE: '/daytopic-info/delete',
    DAY_NEWS_GET: '/daytopic-info/get',
    DAY_NEWS_MODIFY: '/daytopic-info/edit',


    // 值日表：duty-info/add String classid,String comment,String fileid（classid不传时为当前用户所在班级）
    DUTY_ADD: '/duty-info/add',
    DUTY_GET: '/duty-info/get',
    ALBUM_FIND: '/album-info/find',//相册
    ALBUM_DETAIL: '/album-info/get',//相册详情 id
    ALBUM_DELETE: '/album-info/delete-photo',//图片删除 ids
    ALBUMS_DELETE: '/album-info/delete',//相册删除详情 ids


    ALBUM_CREATE: '/album-info/add',//相册详情 id
    ALBUM_UPDATE: '/album-info/edit',//相册详情 id
    ALBUM_UPDATE_DETAIL: '/album-info/photo-edit',//相册详情 id
    QUICK_ACCESS_GET:'/menu-info/get-quick-entry',//快捷访问获取方法
    QUICK_ACCESS_EDIT:'/menu-info/edit-quick-entry', //快捷访问编辑
    STATISTIC_INFO_GET:'/statistic-info/get-all',//获取所有统计数据
    GET_UNREADY_DEVICE:'/statistic-info/get-all',//获取未完善设备信息
};
for (var url in URL_) {
    if ((URL_[url].indexOf('.json?') == -1)) {
        URL_[url] = '/' + config.api_prefix + URL_[url] + '.json';
    } else {
        URL_[url] = '/' + config.api_prefix + URL_[url];
    }
}

// URL.NEWS_CATEGORY = '/classify-info/find-all?type=1';
// URL.NOTICE_CATEGORY = '/classify-info/find-all?type=3';
// URL.ACTIVITY_CATEGORY = '/classify-info/find-all?type=2';

let pureUrl_ = Object.assign({}, URL_);
for (var url in pureUrl_) {
    pureUrl_[url] = pureUrl_[url].slice(0, pureUrl_[url].indexOf('?'));
}
export let pureUrl = pureUrl_;
let md5Url_ = Object.assign({}, URL_);
for (var url in md5Url_) {
    md5Url_[url] = MD5(md5Url_[url].slice(0, md5Url_[url].indexOf('?')));
}
export let md5Url = md5Url_;
URL_.FUN_UPLOAD_PREVIEW = (imageid) => {
    return `/${config.api_prefix}/image/${imageid}`;
};
URL_.FUN_UPLOAD_ALBUM_PHOTO = (albumid) => { //相册图片上传接口
    return `/${config.api_prefix}/upload-image-album/${albumid}.json`;
};
// URL.NEWS_CATEGORY = '/classify-info/find-all?type=1';
// URL.NOTICE_CATEGORY = '/classify-info/find-all?type=3';
// URL.ACTIVITY_CATEGORY = '/classify-info/find-all?type=2';

export function setTitle(title) {
    document.getElementsByTagName('title')[0].innerText = title || lang.title.app_name;
}


export let URL = URL_;
export let URL__ = URL_;
